package cn.ecut.response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Writer;

/**
 * @author lujiapeng
 * @className CodeServlet
 * @description TODO
 * @date 2020/9/11 15:34
 **/
@WebServlet("/codeServlet")
public class CodeServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setCharacterEncoding("UTF-8");
        // 更加建议的写法是使用 HttpServletResponse 常量
        response.setStatus( HttpServletResponse.SC_NOT_FOUND  );
        response.setHeader("content-type" , "text/html; charset=utf-8");
        Writer w = response.getWriter() ;
        w.write("我有，但是不想让你看！");

    }
}
